package main

import (
	"fmt"
	"time"
)

func main() {
	go do()
	for {
		select {
		case i := <-ch:
			fmt.Println(i)
		case <-time.After(time.Second * 3):
			fmt.Println("超时")
		}
	}
}

var ch = make(chan int)

func do() {
	var i int
	for {
		ch <- i
		i++
	}
}
